{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n"
     ]
    }
   ],
   "source": [
    "def longestCommonPrefix():\n",
    "    #暴力解法\n",
    "        re=\"\"\n",
    "        strs=[]\n",
    "        judge=1\n",
    "        if strs:\n",
    "            tmp=strs[0]\n",
    "            #选出最短的字符串\n",
    "            for item in strs:\n",
    "                if len(tmp)>len(item):\n",
    "                    tmp=item\n",
    "            for j in range(len(tmp)):\n",
    "                for i in range(len(strs)):\n",
    "                    if tmp[j]!=strs[i][j]:\n",
    "                        judge=0\n",
    "                        break\n",
    "                    if i==len(strs)-1:\n",
    "                        re+=strs[0][j]\n",
    "                if judge==0:\n",
    "                    break\n",
    "        return re\n",
    "def main():\n",
    "    print(longestCommonPrefix())\n",
    "    \n",
    "main()\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
